/*****************************************************************************/
/**
 *  @file   main.cpp
 *  @author Naohisa Sakamoto
 */
/*----------------------------------------------------------------------------
 *
 *  Copyright (c) Visualization Laboratory, Kyoto University.
 *  All rights reserved.
 *  See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details.
 *
 *  $Id$
 */
/*****************************************************************************/
#include <kvs/Directory>
#include <kvs/AVSField>
#include <util/SPHFile.h>
#include <util/SPHFileToAVSField.h>
#include <iostream>


int main( int argc, char** argv )
{
    const std::string dirname( argv[1] );
    const bool header_only = false;
    const bool absolute_path = true;

    kvs::Directory dir( dirname );
    kvs::FileList::iterator file = dir.fileList().begin();
    kvs::FileList::iterator end = dir.fileList().end();
    while ( file != end )
    {
        kvsbloodvis::util::SPHFile sph( file->filePath( absolute_path), header_only );
        kvs::AVSField avs = kvsbloodvis::util::SPHFileToAVSField( sph );
        avs.write( file->baseName() + ".fld" );
        avs.print( std::cout << std::endl );
        ++file;
    }

    return 0;
}
